package com.study.d012Components;

import javafx.application.Application;
import javafx.geometry.Orientation;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.SplitPane;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

/**
 *
 * SplitPane分隔面板
 *
 */
public class SplitPaneMain extends Application{
	public static void main(String[] args) {
		launch(args);
	}
	@Override
	public void start(Stage stage) throws Exception {
		stage.show();
		BorderPane borderPane = new BorderPane();

		SplitPane sp = new SplitPane();

		//SplitPane需要加在StackPane
		StackPane st1 = new StackPane(new Button("Button01"));
		StackPane st2 = new StackPane(new Button("Button02"));
		StackPane st3 = new StackPane(new Button("Button03"));
		StackPane st4 = new StackPane(new Button("Button04"));

		//设置为垂直分隔
		sp.setOrientation(Orientation.VERTICAL);

		//设置分隔比例（平分4份）
		sp.setDividerPosition(0, 0.25);
		sp.setDividerPosition(1, 0.5);
		sp.setDividerPosition(2, 0.75);
		sp.setDividerPosition(3, 0.1);

		sp.getItems().addAll(st1,st2,st3,st4);

		borderPane.setCenter(sp);

		stage.setScene(new Scene(borderPane, 400, 300));
	}
}
